<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<span>
			<input type="text" id="inputId"/>
			<input type="button" value="猜" onclick='caiShuZi()'/>
			<span id='resultId'></span>
		</span>
		<script type="text/javascript">
			var random = parseInt(Math.random()*100 + 1);
			console.log("radom = " + random);
			function caiShuZi(){
				var num = document.getElementById('inputId').value;
				var resultObj = document.getElementById('resultId');
				if (num == '' || isNaN(num)) {
					resultObj.innerHTML = '<span style="color:red;">不能为空/您输入的不是一个数字</span>';
					return;
				}
				if (num > random) {
					resultObj.innerHTML = '猜大了';
				} else if(num < random) {
					resultObj.innerHTML = '猜小了';
				} else {
					resultObj.innerHTML = '猜对了';
				}
			}
		</script>
	</body>
</html>
